
const mixincomon = {
    data() {
      return {
        setTimeFlag:null,
        optionsEnd:{},
        index:0,
        dataEnd:[],
        optionCureen:{},
        myChart:{},

      }
    },
    created () {

    },
    watch:{
        width(newdata,olddata){
            if(newdata!=olddata){
                this.resizeChart();
            }
        },
        height(newdata,olddata){
            this.resizeChart();
            if(newdata!=olddata){
                this.resizeChart();
            }
        },
        data:{
            handler(olddata,newdata){
                 this.init();
            },
            deep: true
        },
        'screenWidth':function(val){ //监听屏幕宽度变化
            this.resizeChart();

        },
        'screenHeight':function(){ //监听屏幕高度变化
            this.resizeChart();
        },
    },
    props:{
        message:{
            type:String,
            default:'暂无数据'
        },
        rollReverse:{
            type:Boolean,
            default:false,
        },
        roll:{
            type:Boolean,
            default:false,
        },
        rollshow:{
            type:Number,
            default:7,
        },
        rollTime:{
            type:Number,
            default:2000,
        },
        option:{
            type:Object,
            default:()=>{
                return {}
            }
        },
        data:{
            type:Array,
            default:()=>{
                return []
            }
        },
        width:{
            type:String,
            default:"100%"
        },
        height:{
            type:String,
            default:"250px"
        },
    },
    methods: {
        stop(){
            this.setTimeFlag&&clearTimeout(this.setTimeFlag);
        },
        start(){
            this.roll&&this.rollshow<(_.get(this.optionsEnd.series,'0.data')||[]).length&&this.setTime();
        },
        setTime(){

        },
        initChart(echarts,_option){
           // 基于准备好的dom，初始化echarts实例
           this.myChart = this.echarts.init(this.$refs[echarts]);
           this.clearChart();
           // 绘制图表


           this.myChart.setOption(_option||this.options);
        },
        clearChart(){
            if(this.myChart&&this.myChart.clear){
                this.myChart.clear();
            }
        },
        resizeChart(){
            if(this.myChart&&this.myChart.resize){
                // debugger;
                this.$nextTick(()=>{//这里尺寸变了 是demo必须放在nextTick中才能改变
                    this.myChart.resize();
                });
            }
        },


    },
    computed: {

    },
    mounted() {

    }
  };

  export default mixincomon
